import $ from 'dfish-widget';

export function get({ data, src, config }) {
  return $.ajax.get($.urlParam(src, data), config);
}

export function post(event, option) {
  if (event instanceof window.Event) {
    return $(event).ajax(option);
  }
  const { data, src, headers } = event;
  return $.ajax.post(src, data, { headers });
}

export function submit(event, config) {
  return $(event).submit(config);
}

export function cancelToken() {
  return $.ajax.CancelToken.source();
}
